//
//  MainViewController.m
//  Main
//
//  Created by Leon on 4/7/11.
//  Copyright __MyCompanyName__ 2011. All rights reserved.
//

#import "MainViewController.h"
#import "CMobileCloudAppDelegate.h"

@implementation MainViewController
@synthesize btnMyZone,btnFavorite,btnSetting,btnHelp;
@synthesize settingTableViewController,helpTableViewController;


/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] init];
	barButtonItem.title = @"Home";
	self.navigationItem.backBarButtonItem = barButtonItem;
	[barButtonItem release];
	
	self.title = @"CMobileCloud";
	
}



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
	self.btnMyZone		= nil;
	self.btnFavorite	= nil;
	self.btnSetting		= nil;
	self.btnHelp		= nil;
	self.settingTableViewController = nil;
	self.helpTableViewController	= nil;
}


- (void)dealloc {
	[btnMyZone release];
	[btnFavorite release];
	[btnSetting	release];
	[btnHelp release];
	[settingTableViewController release];
	[helpTableViewController release];
	
    [super dealloc];
}

-(IBAction)doBtnMyZone:(id)sender
{
	UIActivityIndicatorView *activityIndicatorView;
	activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
	activityIndicatorView.frame = CGRectMake((self.view.frame.size.width - 40)/2, (self.view.frame.size.height - 40) / 2, 40, 40);
	[self.view addSubview:activityIndicatorView];
	[activityIndicatorView startAnimating];
//	while (1) {
//	
//	}
//	[activityIndicatorView stopAnimating];
//	[activityIndicatorView removeFromSuperview];
//	[activityIndicatorView release];
//	activityIndicatorView = nil;
}

-(IBAction)doBtnFavorite:(id)sender
{
}

-(IBAction)doBtnSetting:(id)sender
{
	if( self.settingTableViewController == nil )
	{
		SettingTableViewController *theSettingController = [[SettingTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
		self.settingTableViewController = theSettingController;
		[theSettingController release];
	}
	CMobileCloudAppDelegate* delegate = (CMobileCloudAppDelegate*)[UIApplication sharedApplication].delegate;
	[delegate.navigationController pushViewController:self.settingTableViewController animated:YES];
}

-(IBAction)doBtnHelp:(id)sender
{
	if( self.helpTableViewController == nil )
	{
		HelpTableViewController *theHelpController = [[HelpTableViewController alloc] initWithStyle:UITableViewStylePlain];
		self.helpTableViewController = theHelpController;
		[theHelpController release];
	}
	CMobileCloudAppDelegate* delegate = (CMobileCloudAppDelegate*)[UIApplication sharedApplication].delegate;
	[delegate.navigationController pushViewController:self.helpTableViewController animated:YES];
}

@end
